using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;

namespace FoundationLib.Ifc.Authorisation.Configuration
{
	/// <summary>
	/// This class represents the settings used to connect to a directory service.
	/// </summary>
	public class AuthorisationConfigElement : ConfigurationElement
	{
		/// <summary>
		/// Creates a new instance
		/// </summary>
		public AuthorisationConfigElement()
			: base()
		{
		}

		/// <summary>
		/// Gets the name of this configuration element.
		/// </summary>
		[ConfigurationProperty("name", IsRequired = true, IsKey = true)]
		public string Name
		{
			get
			{
				return (this["name"] as string);
			}
		}

		/// <summary>
		/// Gets the directory service host.
		/// </summary>
		[ConfigurationProperty("server", IsRequired = true)]
		public string Server
		{
			get
			{
				return (this["server"] as string);
			}
		}

		/// <summary>
		/// Gets the port used to connect to the directory service.
		/// </summary>
		[ConfigurationProperty("port", IsRequired = false, DefaultValue = 3268)]
		public int Port
		{
			get
			{
				return ((int)this["port"]);
			}
		}

		/// <summary>
		/// Gets the base DN used for binding against the directory service.
		/// </summary>
		[ConfigurationProperty("baseDn", IsRequired = false)]
		public string BaseDn
		{
			get
			{
				return (this["baseDn"] as string);
			}
		}

		/// <summary>
		/// Gets the DN of the user used for the initial bind with the service.
		/// </summary>
		[ConfigurationProperty("bindUserDn", IsRequired = false, DefaultValue = "")]
		public string BindUserDn
		{
			get
			{
				return (this["bindUserDn"] as string);
			}
		}

		/// <summary>
		/// Gets the password of the user used for the initial bind with the service.
		/// </summary>
		[ConfigurationProperty("bindUserPassword", IsRequired = false, DefaultValue = "")]
		public string BindUserPassword
		{
			get
			{
				return (this["bindUserPassword"] as string);
			}
		}

		/// <summary>
		/// Gets the attribute defining the user identifier on the directory service.
		/// </summary>
		[ConfigurationProperty("uidAttribute", IsRequired = false, DefaultValue = "sAMAccountName")]
		public string UidAttribute
		{
			get
			{
				return (this["uidAttribute"] as string);
			}
		}

		/// <summary>
		/// Gets the fully qualified name of the authorisation service provider.
		/// </summary>
		[ConfigurationProperty("implementation", IsRequired = true)]
		public string Implementation
		{
			get
			{
				return (this["implementation"] as string);
			}
		}
	}
}
